package com.nanhang.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nanhang.entity.Order;
import com.nanhang.mapper.OrderMapper;
import com.nanhang.service.IOrderService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nanhang.util.PageResult;
import com.nanhang.vo.OrderVo;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author jsj
 * @since 2025-01-13
 */
@Service
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements IOrderService {
    @Override
    public PageResult<Order> search(Integer page, Integer pageSize, OrderVo vo) {

        QueryWrapper<Order> wrapper = new QueryWrapper<>();
        wrapper.like(StrUtil.isNotBlank(vo.getShippingName()), "shipping_name", vo.getShippingName());
        wrapper.like(StrUtil.isNotBlank(vo.getShippingCode()), "shipping_code", vo.getShippingCode());
        wrapper.like(StrUtil.isNotBlank(vo.getUserId()), "user_id", vo.getUserId());

        Page<Order> page1 = this.page(new Page<>(page, pageSize), wrapper);



        return new PageResult<>(page1.getRecords(),page1.getTotal());
    }
}
